import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 10 - 19
 * Time: 16:59
 */
//牛客 计算日期到天数转换
public class Solution15 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int y = in.nextInt();
            int m = in.nextInt();
            int d = in.nextInt();
            int sum = 0;
            int[] day = new int[]{31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
            if (m >= 2) {
                sum += day[m - 2];
            }
            sum += d;
            if(m >= 3) {
                if(y % 400 == 0 || (y % 100 != 0 && y % 4 == 0)) {
                    sum += 1;
                }
            }
            System.out.println(sum);
        }
    }
}
